﻿var $reset = '';
$(function () {
    $('#overlay,.navigate-body').on('touchmove', function (a) {
        a.preventDefault();
        a.stopPropagation();
    });
    $('#menu').on('tap', function (a) {
        a.preventDefault();
        a.stopPropagation();
        $('#overlay').show();
        $('.navigate-body').translate({duration: 0.3, value: 0});
    });
    $('#overlay').on('tap.navigate', function (a) {
        a.stopPropagation();
        $('.navigate-body').translate({
            duration: 0.3, value: '100%', callback: function () {
                $('#overlay').hide();
            }
        });
    });
});
$(function () {
    var e = $(window).height();
    var d = $('.header-body').outerHeight(true) || 0;
    var c = $('.search-body').outerHeight(true) || 0;
    var a = $('.filter-body').outerHeight(true) || 0;
    var b = $('.footer-body').outerHeight(true) || 0;
    $('.article-body').css('min-height', e - d - c - a - b);
});
$(function () {
    var o = null;
    var f = $('.filter-layer');
    var c = $('.filter-body');
    var l = $('.filter-list');
    var h = $('#overlay');
    if (app.reset) {
        if (app.reset == 'housetype') {
            var y = -1;
            $('.js-filter-title .items').each(function (b) {
                if ($(this).hasClass('js-title-housetype')) {
                    y = b;
                }
            });
            if (y != -1) {
                u(y);
            }
        }
        if (app.reset == 'area') {
            var y = -1;
            $('.js-filter-title .items').each(function (b) {
                if ($(this).hasClass('js-title-area')) {
                    y = b;
                }
            });
            if (y != -1) {
                u(y);
            }
        }
        if (app.reset == 'region-metro') {
            var y = -1;
            $('.js-filter-title .items').each(function (b) {
                if ($(this).hasClass('js-title-region')) {
                    y = b;
                }
            });
            if (y != -1) {
                u(y);
            }
        }
        if (app.reset == 'more') {
            var e = -1;
            $('.js-filter-title .items').each(function (b) {
                if ($(this).hasClass('js-title-more')) {
                    e = b;
                }
            });
            if (e != -1) {
                u(e);
            }
        }
        if (app.reset == 'price') {
            var y = -1;
            $('.js-filter-title .items').each(function (b) {
                if ($(this).hasClass('js-title-price')) {
                    y = b;
                }
            });
            if (y != -1) {
                u(y);
            }
        }
    }

    function u(b) {
        h.show();
        f.slideDown(200);
        l.hide().eq(b).show();
        f.find('.filter-body .items:eq(' + b + ')').addClass('current').siblings('.current').removeClass('current');
    }

    function r() {
        f.hide();
        l.hide();
        h.hide();
    }

    function B() {
        var C = $('.header-body').outerHeight(true) + $('.search-body').outerHeight(true);
        var b = c.outerHeight(true);
        if ($(document).scrollTop() >= C) {
            $('.filter-body:first').css('position', 'fixed');
            $('.article-body').css('margin-top', b);
        } else {
            $('.filter-body:first').css('position', 'relative');
            $('.article-body').css('margin-top', 0);
        }
    }

    $(document).on('scroll.filter', function () {
        if (o) {
            clearTimeout(o);
        }
        o = setTimeout(function () {
            B();
        }, 30);
    });
    h.on('touchmove.filter', function (b) {
        b.preventDefault();
        b.stopPropagation();
    });
    f.on('touchmove.filter', function (b) {
        b.preventDefault();
        b.stopPropagation();
    });
    h.on('tap.filter', function (b) {
        b.preventDefault();
        b.stopPropagation();
        r();
    });
    var p = $('#fromPrice').val();
    var a = $('#toPrice').val();
    c.find('.items').on('tap', function (b) {
        b.preventDefault();
        b.stopPropagation();
        if ($(this).hasClass('current') && f.css('display') !== 'none') {
            r();
        } else {
            u($(this).index());
            t();
            j(p, a);
        }
    });
    var x = false;
    var z = {x: 0, y: 0};
    var q = {x: 0, y: 0};
    var d = $('.range');
    var n = d.find('.range-value').data('min');
    var w = d.find('.range-value').data('max');
    var i = d.find('.range-value').data('unit');
    var v = n;
    var s = w;
    var k;
    var g;
    var A = $('.first-slider').data('number') || 0;
    var m = $('.last-slider').data('number') || 0;

    function t() {
        k = d.width();
        g = k / (w - n);
    }

    function j(D, C) {
        v = D || n;
        s = C || w;
        A = Math.round((v - n) * g);
        m = Math.round((w - s) * g);
        if (A < 0) {
            A = 0;
            v = n;
        } else {
            if (A > k - m - Math.round(g)) {
                A = k - m - Math.round(g);
                v = s - 1;
            } else {
                v = Math.round(A / g) + n;
            }
        }
        $('.first-slider').css({'left': A - 20});
        $('.range-value').css({'left': A});
        var b = v * i;
        if (v === n) {
            b = '不限';
        }
        $('.first-slider').find('.text-value').text(b);
        $('.first-slider').data('number', A);
        if (s - v < 4) {
            $('.first-slider').find('.text-value').css({'left': -18});
        } else {
            $('.first-slider').find('.text-value').css({'left': -9});
        }
        if (m < 0) {
            m = 0;
            s = w;
        } else {
            if (m > k - A - Math.round(g)) {
                m = k - A - Math.round(g);
                s = v + 1;
            } else {
                s = w - Math.round(m / g);
            }
        }
        $('.last-slider').css({'right': m - 20});
        $('.range-value').css({'right': m});
        var b = s * i;
        if (s === w) {
            b = '不限';
        }
        $('.last-slider').find('.text-value').text(b);
        $('.last-slider').data('number', m);
        if (s - v < 4) {
            $('.last-slider').find('.text-value').css({'left': 0});
        } else {
            $('.last-slider').find('.text-value').css({'left': -9});
        }
    }

    d.on('touchstart', '.first-slider', function (b) {
        $.extend(z, {x: b.originalEvent.touches[0].pageX, y: b.originalEvent.touches[0].pageY});
    });
    d.on('touchmove', '.first-slider', function (C) {
        C.originalEvent.preventDefault();
        C.originalEvent.stopPropagation();
        $.extend(q, {x: C.originalEvent.touches[0].pageX, y: C.originalEvent.touches[0].pageY});
        x = true;
        A = $(this).data('number') + q.x - z.x;
        if (A < 0) {
            A = 0;
            v = n;
        } else {
            if (A > k - m - Math.round(g)) {
                A = k - m - Math.round(g);
                v = s - 1;
            } else {
                v = Math.round(A / g) + n;
            }
        }
        $(this).css({'left': A - 20});
        $('.range-value').css({'left': A});
        var b = v * i;
        if (v === n) {
            b = '不限';
        }
        $(this).find('.text-value').addClass('orange-text').text(b);
    });
    d.on('touchend', '.first-slider', function (b) {
        if (x) {
            x = false;
            $(this).data('number', A);
            $(this).find('.text-value').removeClass('orange-text');
            if (s - v < 4) {
                $(this).find('.text-value').css({'left': -18});
            } else {
                $(this).find('.text-value').css({'left': -9});
            }
        }
    });
    d.on('touchstart', '.last-slider', function (b) {
        $.extend(z, {x: b.originalEvent.touches[0].pageX, y: b.originalEvent.touches[0].pageY});
    });
    d.on('touchmove', '.last-slider', function (C) {
        C.originalEvent.preventDefault();
        C.originalEvent.stopPropagation();
        $.extend(q, {x: C.originalEvent.touches[0].pageX, y: C.originalEvent.touches[0].pageY});
        x = true;
        m = $(this).data('number') - q.x + z.x;
        if (m < 0) {
            m = 0;
            s = w;
        } else {
            if (m > k - A - Math.round(g)) {
                m = k - A - Math.round(g);
                s = v + 1;
            } else {
                s = w - Math.round(m / g);
            }
        }
        $(this).css({'right': m - 20});
        $('.range-value').css({'right': m});
        var b = s * i;
        if (s === w) {
            b = '不限';
        }
        $(this).find('.text-value').addClass('orange-text').text(b);
    });
    d.on('touchend', '.last-slider', function (b) {
        if (x) {
            x = false;
            $(this).data('number', m);
            $(this).find('.text-value').removeClass('orange-text');
            if (s - v < 4) {
                $(this).find('.text-value').css({'left': 0});
            } else {
                $(this).find('.text-value').css({'left': -9});
            }
        }
    });
});
$(function () {
    $('#overlay,.orderby-layer').on('touchmove', function (a) {
        a.preventDefault();
        a.stopPropagation();
    });
    $('.order-by').on('tap', function (a) {
        a.preventDefault();
        a.stopPropagation();
        $('#overlay').show();
        $('.orderby-layer').slideDown();
    });
    $('#overlay').on('tap.navigate', function (a) {
        a.preventDefault();
        a.stopPropagation();
        $('#overlay').hide();
        $('.orderby-layer').hide();
    });
    $('.orderby-layer .items').on('tap', function (a) {
        a.preventDefault();
        a.stopPropagation();
        setTimeout(function () {
            $('#overlay').hide();
            $('.orderby-layer').hide();
        }, 200);
        location.href = $(this).attr('href');
    });
});
$(function () {
    var b = null;

    function a() {
        var c = $(window).height() / 3;
        if ($(document).scrollTop() > c) {
            $('.go-top').show();
        } else {
            $('.go-top').hide();
        }
    }

    $(document).on('scroll.goTop', function () {
        if (b) {
            clearTimeout(b);
        }
        b = setTimeout(a, 30);
    });
    $('.go-top').on('tap', function (c) {
        c.preventDefault();
        c.stopPropagation();
        $('html,body').animate({'scrollTop': 0}, 300);
    });
    $('.js-city').on('tap', function (c) {
        c.preventDefault();
        c.stopPropagation();
        if ($('.select-box').css('display') === 'none') {
            $('.select-box').show();
        } else {
            $('.select-box').hide();
        }
    });
    $(document).on('tap.searchType', function (c) {
        $('.select-box').hide();
    });
    $('.select-box .option').on('tap', function (c) {
        c.preventDefault();
        c.stopPropagation();
        location.href = $(this).attr('href');
    });
});
$(function () {
    var e = $('.filter-layer');
    var m = $('.filter-list');
    var g = $('#overlay');

    function r() {
        e.hide();
        m.hide();
        g.hide();
    }

    var b = $('.range');
    var h = 'data-subcontent', v = 'js-subcontent-';
    $('.parent .js-at-last').on('tap', cellP = function (B) {
        B.preventDefault();
        B.stopPropagation();
        var A = $(this);
        var z = A.siblings('.current');
        var y = A.attr('href');
        A.addClass('current');
        z.removeClass('current');
        setTimeout(function () {
            r();
        }, 200);
        location.href = y;
    });
    $('.parent').on('tap', 'a[data-subcontent]', cellP = function (A) {
        A.preventDefault();
        A.stopPropagation();
        var z = $(this);
        if (!z.hasClass('current')) {
            var y = z.siblings('.current');
            z.addClass('current');
            y.removeClass('current');
            if (y.data('subcontent')) {
                s(y.attr(h), false);
            }
            s(z.attr(h), true);
        }
    });
    $('.subcontent .slide').on('tap', '.items', cellP = function (A) {
        A.preventDefault();
        A.stopPropagation();
        var z = $(this);
        if (!z.hasClass('current')) {
            var y = z.siblings('.current');
            z.addClass('current');
            y.removeClass('current');
            if (y.data('subcontent')) {
                s(y.attr(h), false);
            }
            s(z.attr(h), true);
        }
    });
    $('.subcontent .slide .js-at-last').on('tap', cellA = function (E) {
        E.preventDefault();
        E.stopPropagation();
        var D = $(this), C = D.siblings('.current'), y = D.attr('href'), A = D.attr('type');
        D.addClass('current');
        C.removeClass('current');
        var z = '/nearby';
        if (y.lastIndexOf(z) > 0) {
            $('#location').val('location');
            i(D);
            return false;
        }
        var B = '/around';
        if (y.lastIndexOf(B) > 0) {
            D.addClass('current');
        }
        setTimeout(function () {
            r();
        }, 200);
        location.href = y;
    });
    $('.childcontent .slide .js-at-last').on('tap', cellA = function (E) {
        E.preventDefault();
        E.stopPropagation();
        var D = $(this), C = D.siblings('.current'), y = D.attr('href'), A = D.attr('type');
        D.addClass('current');
        C.removeClass('current');
        var z = '/nearby';
        if (y.lastIndexOf(z) > 0) {
            $('#location').val('location');
            i(D);
            return false;
        }
        var B = '/around';
        if (y.lastIndexOf(B) > 0) {
            D.addClass('current');
        }
        setTimeout(function () {
            r();
        }, 200);
        if (app.location) {
            var F = 'location=' + app.location;
            if (y.indexOf(F + '&') != -1) {
                y = y.replace('location=' + app.location + '&', '');
            } else {
                y = y.replace('location=' + app.location, '');
            }
        }
        location.href = y;
    });

    function s(A, B) {
        if (A) {
            var z = $('.' + v + A);
            if (z.is(':' + (B ? 'hidden' : 'visible'))) {
                if (B) {
                    z.show();
                } else {
                    z.hide();
                }
                var y = z.find('a.current');
                if (y && y.length > 0) {
                    s(y.attr(h), B);
                }
            }
        }
    }

    $('.js-sub-region').on('tap', function (z) {
        z.preventDefault();
        z.stopPropagation();
        var y = $(this).find('.icon');
        $(this).toggleClass('current');
        if (y.hasClass('icon-yixuanze')) {
            y.removeClass('icon-yixuanze').addClass('icon-weixuanze');
        } else {
            y.addClass('icon-yixuanze').removeClass('icon-weixuanze');
        }
        $(this).parent().find('.js-at-last').removeClass('current');
    });
    $('.js-metro-station').on('tap', function (z) {
        z.preventDefault();
        z.stopPropagation();
        var y = $(this).find('.icon');
        $(this).toggleClass('current');
        if (y.hasClass('icon-yixuanze')) {
            y.removeClass('icon-yixuanze').addClass('icon-weixuanze');
        } else {
            y.addClass('icon-yixuanze').removeClass('icon-weixuanze');
        }
        $(this).parent().find('.js-at-last').removeClass('current');
    });
    $('.js-sub-region-cancel').on('tap', function (z) {
        z.preventDefault();
        z.stopPropagation();
        var y = $('.js-region-first').hasClass('current');
        $('.js-region-area').each(function (A) {
            $(this).removeClass('current');
        });
        $('.js-subcontent-region').find('.js-at-last').first().addClass('current');
        $('.js-sub-region').each(function (B) {
            $(this).removeClass('current');
            var A = $(this).find('.icon');
            if (A.hasClass('icon-yixuanze')) {
                A.removeClass('icon-yixuanze').addClass('icon-weixuanze');
            }
        });
        $('.js-metro-line').each(function (A) {
            $(this).removeClass('current');
        });
        $('.js-subcontent-metro').find('.js-at-last').addClass('current');
        $('.js-metro-station').each(function (B) {
            $(this).removeClass('current');
            var A = $(this).find('.icon');
            if (A.hasClass('icon-yixuanze')) {
                A.removeClass('icon-yixuanze').addClass('icon-weixuanze');
            }
        });
        $('.childcontent').find('.js-at-last').addClass('current');
        $reset = 'region-metro';
        t();
    });
    $('.js-sub-region-ok').on('tap', function (y) {
        y.preventDefault();
        y.stopPropagation();
        t();
    });

    function t() {
        var y = $('.js-region-first').hasClass('current');
        var F = $('#params').val();
        if (F != '') {
            if (app.metro) {
                if (F.indexOf(app.metro) != -1) {
                    var C = new RegExp('(' + app.metro + '-?|-' + app.metro + '+$)');
                    F = F.replace(C, '');
                }
            }
        }
        var B = '/';
        var z = app.ctx + B + app.biz;
        if (app.biz == 'officerent') {
            z = app.ctx + B + 'office/rent';
        }
        if (app.biz == 'officesale') {
            z = app.ctx + B + 'office/sale';
        }
        if (o != '') {
            z = z.replace(o, '');
        }
        z = c(z);
        var E = '';
        if (y == true) {
            E = $('.js-subcontent-region').find('.current').data('subcontent');
            if (E != undefined) {
                E += '-';
                $('.js-subcontent-' + E.substring(0, E.length - 1) + ' .js-sub-region').each(function (H) {
                    if ($(this).hasClass('current')) {
                        var G = $(this).data('v').split('-');
                        E += G[1] + '-';
                    }
                });
                if (E != '') {
                    E = E.substring(0, E.length - 1);
                }
            }
        }
        var D = '';
        if (y == false) {
            D = $('.js-subcontent-metro').find('.current').data('subcontent');
            if (D != undefined) {
                D = D + '-';
                $('.js-subcontent-' + D.substring(0, D.length - 1) + ' .js-metro-station').each(function (G) {
                    if ($(this).hasClass('current')) {
                        var H = $(this).data('v').split('-');
                        D += H[1] + '-';
                    }
                });
                if (D != '') {
                    D = D.substring(0, D.length - 1);
                }
            }
        }
        if (y == true) {
            if (E != undefined) {
                if (F != '') {
                    z += B + E + '/' + F;
                } else {
                    z += B + E;
                }
            } else {
                if (F != '') {
                    z += B + F;
                }
            }
        }
        if (y == false) {
            if (D != undefined) {
                if (F != '') {
                    z += B + D + '-' + F;
                } else {
                    z += B + D;
                }
            } else {
                if (F != '') {
                    z += B + F;
                }
            }
        }
        if ('/' === z.charAt(z.length - 1)) {
            z = z.substring(0, z.length - 1);
        }
        var A = '?';
        if (o != '') {
            z += A + o;
            A = '&';
        }
        if (app.personId) {
            z += A + 'personId=' + app.personId;
            A = '&';
        }
        var y = false;
        if (app.gardenId && app.schoolId) {
            y = true;
            z += A + 'gardenId=' + app.gardenId;
            z += '&schoolId=' + app.schoolId;
            A = '&';
        }
        if (!y && app.schoolId) {
            z += A + 'schoolId=' + app.schoolId;
            A = '&';
        }
        if (app.keyword) {
            z += A + 'keyword=' + app.keyword;
            A = '&';
        }
        if (app.fromCity) {
            z += A + 'fromCity=' + app.fromCity;
            A = '&';
        }
        if (app.from) {
            z += A + 'from=' + app.from;
            A = '&';
        }
        if ($reset) {
            z += A + 'reset=' + $reset;
        }
        if (app.location) {
            z += A + 'location=' + app.location;
        }
        location.href = z;
    }

    $('.js-area').on('tap', function (z) {
        z.preventDefault();
        z.stopPropagation();
        $(this).toggleClass('current');
        var y = $(this).find('.icon');
        if (y.hasClass('icon-yixuanze')) {
            y.removeClass('icon-yixuanze').addClass('icon-weixuanze');
        } else {
            y.addClass('icon-yixuanze').removeClass('icon-weixuanze');
        }
        $(this).parent().find('.js-at-last').removeClass('current');
    });
    $('.js-area-cancel').on('tap', function (y) {
        y.preventDefault();
        y.stopPropagation();
        $('.js-area').each(function (A) {
            $(this).removeClass('current');
            var z = $(this).find('.icon');
            if (z.hasClass('icon-yixuanze')) {
                z.removeClass('icon-yixuanze').addClass('icon-weixuanze');
            }
            $(this).parent().find('.js-at-last').addClass('current');
        });
        if ($('#officeAreas').val()) {
            $reset = 'area';
            f();
        }
    });
    $('.js-area-ok').on('tap', function (y) {
        y.preventDefault();
        y.stopPropagation();
        f();
    });

    function f() {
        var F = $('#params').val();
        var C = $('#officeAreas').val();
        var D = '';
        if (F !== '') {
            D = '-';
            F = '/' + F;
        } else {
            D = '/';
        }
        var A = $('#urlTemp').val().replace('{xxx}', F);
        if (o != '') {
            A = A.replace(o, '');
        }
        A = c(A);
        var z = '';
        $('.js-area').each(function (G) {
            if ($(this).hasClass('current')) {
                z += $(this).data('v') + '-';
            }
        });
        if (z !== '') {
            z = z.substring(0, z.length - 1);
        }
        if (C !== '') {
            if (z === '') {
                var E = new RegExp('(' + C + '-?|-' + C + '+$)');
                A = A.replace(E, '');
            } else {
                A = A.replace(C, z);
            }
        } else {
            if (z !== '') {
                A += D + z;
            }
        }
        if ('/' === A.charAt(A.length - 1)) {
            A = A.substring(0, A.length - 1);
        }
        var B = '?';
        if (o != '') {
            A += B + o;
            B = '&';
        }
        if (app.personId) {
            A += B + 'personId=' + app.personId;
            B = '&';
        }
        var y = false;
        if (app.gardenId && app.schoolId) {
            y = true;
            A += B + 'gardenId=' + app.gardenId;
            A += '&schoolId=' + app.schoolId;
            B = '&';
        }
        if (!y && app.schoolId) {
            A += B + 'schoolId=' + app.schoolId;
            B = '&';
        }
        if (app.keyword) {
            A += B + 'keyword=' + app.keyword;
            B = '&';
        }
        if (app.fromCity) {
            A += B + 'fromCity=' + app.fromCity;
            B = '&';
        }
        if (app.from) {
            A += B + 'from=' + app.from;
            B = '&';
        }
        if ($reset) {
            A += B + 'reset=' + $reset;
        }
        if (app.location) {
            A += B + 'location=' + app.location;
        }
        location.href = A;
    }

    $('.js-house-type').on('tap', function (z) {
        z.preventDefault();
        z.stopPropagation();
        $(this).toggleClass('current');
        var y = $(this).find('.icon');
        if (y.hasClass('icon-yixuanze')) {
            y.removeClass('icon-yixuanze').addClass('icon-weixuanze');
        } else {
            y.addClass('icon-yixuanze').removeClass('icon-weixuanze');
        }
    });
    $('.js-house-type-cancel').on('tap', function (y) {
        y.preventDefault();
        y.stopPropagation();
        $('.js-house-type-parent').data('v', '');
        $('.js-house-type').each(function (A) {
            $(this).removeClass('current');
            var z = $(this).find('.icon');
            if (z.hasClass('icon-yixuanze')) {
                z.removeClass('icon-yixuanze').addClass('icon-weixuanze');
            }
        });
        if (app.bedRooms) {
            $reset = 'housetype';
            n();
        }
    });
    var q = $('#fromPriceVal').val();
    var a = $('#toPriceVal').val();
    var x = $('#fromUnitPriceVal').val();
    var w = $('#toUnitPriceVal').val();
    var o = '';
    if (q && a) {
        o = 'fromPrice=' + q + '&toPrice=' + a;
    }
    if (x && w) {
        if (o) {
            o += '&fromUnitPrice=' + x + '&toUnitPrice=' + w;
        } else {
            o = 'fromUnitPrice=' + x + '&toUnitPrice=' + w;
        }
    }
    $('.js-house-type-ok').on('tap', function (y) {
        y.preventDefault();
        y.stopPropagation();
        n();
    });

    function n() {
        var E = $('#params').val();
        var y = $('#bedRooms').val();
        var C = '';
        if (E !== '') {
            C = '-';
            E = '/' + E;
        } else {
            C = '/';
        }
        var A = $('#urlTemp').val().replace('{xxx}', E);
        if (o != '') {
            A = A.replace(o, '');
        }
        A = c(A);
        var F = '';
        $('.js-house-type').each(function (G) {
            if ($(this).hasClass('current')) {
                F += $(this).data('v') + '-';
            }
        });
        if (F !== '') {
            F = F.substring(0, F.length - 1);
        }
        if (y !== '') {
            if (F === '') {
                var D = new RegExp('(' + y + '-?|-' + y + '+$)');
                A = A.replace(D, '');
            } else {
                A = A.replace(y, F);
            }
        } else {
            if (F !== '') {
                A += C + F;
            }
        }
        if ('/' === A.charAt(A.length - 1)) {
            A = A.substring(0, A.length - 1);
        }
        var B = '?';
        if (o != '') {
            A += B + o;
            B = '&';
        }
        if (app.personId) {
            A += B + 'personId=' + app.personId;
            B = '&';
        }
        var z = false;
        if (app.gardenId && app.schoolId) {
            z = true;
            A += B + 'gardenId=' + app.gardenId;
            A += '&schoolId=' + app.schoolId;
            B = '&';
        }
        if (!z && app.schoolId) {
            A += B + 'schoolId=' + app.schoolId;
            B = '&';
        }
        if (app.keyword) {
            A += B + 'keyword=' + app.keyword;
            B = '&';
        }
        if (app.fromCity) {
            A += B + 'fromCity=' + app.fromCity;
            B = '&';
        }
        if (app.from) {
            A += B + 'from=' + app.from;
            B = '&';
        }
        if ($reset) {
            A += B + 'reset=' + $reset;
        }
        if (app.location) {
            A += B + 'location=' + app.location;
        }
        location.href = A;
    }

    function c(y) {
        if (app.personId) {
            y = y.replace('personId=' + app.personId, '');
        }
        if (app.gardenId && app.schoolId) {
            y = y.replace('gardenId=' + app.gardenId, '');
            y = y.replace('&schoolId=' + app.schoolId, '');
        }
        if (app.schoolId) {
            y = y.replace('schoolId=' + app.schoolId, '');
        }
        if (app.keyword) {
            y = y.replace('keyword=' + app.keyword, '');
        }
        if (app.fromCity) {
            y = y.replace('fromCity=' + app.fromCity, '');
        }
        if (app.from) {
            y = y.replace('from=' + app.from, '');
        }
        if (app.location) {
            y = y.replace('location=' + app.location, '');
        }
        y = y.replace(/\?/g, '');
        y = y.replace(/\&/g, '');
        return y;
    }

    function k(y) {
        $('#message').text(y);
        $('.js-layer-tip').removeClass('hide');
        setTimeout(function () {
            $('.js-layer-tip').addClass('hide');
        }, 1000);
    }

    var q = $('#fromPriceVal').val();
    var a = $('#toPriceVal').val();
    var x = $('#fromUnitPriceVal').val();
    var w = $('#toUnitPriceVal').val();
    var o = '';
    if (q && a) {
        o = 'fromPrice=' + q + '&toPrice=' + a;
    }
    if (x && w) {
        if (o) {
            o += '&fromUnitPrice=' + x + '&toUnitPrice=' + w;
        } else {
            o = 'fromUnitPrice=' + x + '&toUnitPrice=' + w;
        }
    }
    var u = false;
    $('.complete-body').on('tap', '.js-price-cancel', function (y) {
        y.preventDefault();
        y.stopPropagation();
        $('.js-filter-title a').last().removeClass('current');
        var z = $('.checkbox-body .price');
        z.find('a').removeClass('current');
        z.each(function (A, B) {
            $(B).data('v', '');
        });
        $('#minUnitPrice').val('');
        $('#maxUnitPrice').val('');
        $('#minPrice').val('');
        $('#maxPrice').val('');
        u = true;
        if (app.price || app.unitPrice || $('#fromPriceVal').val() || $('#fromUnitPriceVal').val()) {
            $reset = 'price';
            l();
        }
    });
    $('#minPrice, #maxPrice').on('click', function () {
        $('.js-price-box').children().each(function () {
            if ($(this).hasClass('current')) {
                $(this).removeClass('current');
                var A = $(this).closest('.price');
                var z = new RegExp($(this).data('v') + '-?|-?' + $(this).data('v'));
                var y = A.data('v');
                if (y) {
                    y = y.replace(z, '');
                }
                A.data('v', y);
            }
        });
    });
    $('#minUnitPrice, #maxUnitPrice').on('click', function () {
        $('.js-unitPrice-box').children().each(function () {
            if ($(this).hasClass('current')) {
                $(this).removeClass('current');
                var A = $(this).closest('.price');
                var z = new RegExp($(this).data('v') + '-?|-?' + $(this).data('v'));
                var y = A.data('v');
                if (y) {
                    y = y.replace(z, '');
                }
                A.data('v', y);
            }
        });
    });
    $('.complete-body').on('tap', '.js-price-ok', function (C) {
        C.preventDefault();
        C.stopPropagation();
        var A = $('#minPrice').val();
        var B = $('#maxPrice').val();
        var z = $('#minUnitPrice').val();
        var D = $('#maxUnitPrice').val();
        var y = /^(\d{1,4}|(\d{1,2}\.\d{1}))$/;
        if ((z && !y.test(z))) {
            k('格式错误，小数点后只可输入一位');
            return;
        }
        y = /^[0-9]*$/;
        if ((A && !y.test(A)) || (B && !y.test(B))) {
            k('总价格式输入错误');
            return;
        }
        if (A && B && (parseInt(B) < parseInt(A))) {
            k('总价最小值不能大于最大值');
            return;
        }
        if (z && D && (parseInt(z) > parseInt(D))) {
            k('单价的最小值不能大于最大值');
            return;
        }
        if (A || B) {
            $('.js-price-box').children().each(function () {
                if ($(this).hasClass('current')) {
                    $(this).removeClass('current');
                    var G = $(this).closest('.price');
                    var F = new RegExp($(this).data('v') + '-?|-?' + $(this).data('v'));
                    var E = G.data('v');
                    if (E) {
                        E = E.replace(F, '');
                    }
                    G.data('v', E);
                }
            });
        }
        if (z || D) {
            $('.js-unitPrice-box').children().each(function () {
                if ($(this).hasClass('current')) {
                    $(this).removeClass('current');
                    var G = $(this).closest('.price');
                    var F = new RegExp($(this).data('v') + '-?|-?' + $(this).data('v'));
                    var E = G.data('v');
                    if (E) {
                        E = E.replace(F, '');
                    }
                    G.data('v', E);
                }
            });
        }
        u = false;
        l();
    });

    function l() {
        var C = $('#params').val();
        var J = $('#unitPrice').val();
        var F = $('#price').val();
        var K = {};
        var I = $('.checkbox-body .price');
        I.each(function (N, Q) {
            var P = $(Q);
            if (P.hasClass('js-multiple')) {
                if (u) {
                    if (F != '') {
                        var O = new RegExp('(' + F + '-?|-' + F + '+$)');
                        C = C.replace(O, '');
                    }
                    if (J != '') {
                        var O = new RegExp('(' + J + '-?|-' + J + '+$)');
                        C = C.replace(O, '');
                    }
                } else {
                    K[P.data('k')] = P.data('v');
                }
            } else {
                C = p(C, P.data('k'), P.data('v'));
            }
        });
        if (C != '') {
            C = '/' + C;
        }
        setTimeout(function () {
            r();
        }, 200);
        var y = $('#urlTemp').val().replace('{xxx}', C);
        if (o != '') {
            y = y.replace(o, '');
        }
        y = c(y);
        if ('/' === y.charAt(y.length - 1)) {
            y = y.substring(0, y.length - 1);
        }
        if (!$.isEmptyObject(K) && K != null) {
            var B = (C == '') ? '/' : '-';
            if (app.location) {
                y += M + 'location=' + app.location;
            }
            if (F != '') {
                y = y.replace(F, '{ooo}');
            }
            if (J != '') {
                y = y.replace(J, '{ggg}');
            }
            var G = 0;
            $.each(K, function (N, O) {
                var P;
                if (O) {
                    if (N == 'unitPrice' || N == 'price') {
                        P = O;
                    } else {
                        P = N + '=' + O;
                    }
                } else {
                    P = '';
                }
                if (P) {
                    G += 1;
                    if (N == 'price' && F != '') {
                        y = y.replace('{ooo}', P);
                    } else {
                        if (N == 'unitPrice' && J != '') {
                            y = y.replace('{ggg}', P);
                        } else {
                            if (G > 1) {
                                B = '-';
                            }
                            y += B + P;
                        }
                    }
                }
            });
        }
        var L = new RegExp('({xxx}-?|-' + '{xxx}+$)');
        y = y.replace(L, '');
        L = new RegExp('({ooo}-?|-' + '{ooo}+$)');
        y = y.replace(L, '');
        L = new RegExp('({ggg}-?|-' + '{ggg}+$)');
        y = y.replace(L, '');
        var E = $('#minPrice').val();
        var A = $('#maxPrice').val();
        var z = $('#minUnitPrice').val();
        var D = $('#maxUnitPrice').val();
        if (y.substr(-1) === '/') {
            y = y.substring(0, y.length - 1);
        }
        var M = '?';
        if (E || A) {
            if (!E) {
                E = 0;
            }
            if (!A) {
                A = 999999;
            }
            y += M + 'fromPrice=' + E + '&toPrice=' + A;
            M = '&';
        }
        if (z || D) {
            if (!z) {
                z = 0;
            }
            if (!D) {
                D = 9999;
            }
            y += M + 'fromUnitPrice=' + z + '&toUnitPrice=' + D;
        }
        if (app.personId) {
            y += M + 'personId=' + app.personId;
            M = '&';
        }
        var H = false;
        if (app.gardenId && app.schoolId) {
            H = true;
            y += M + 'gardenId=' + app.gardenId;
            y += '&schoolId=' + app.schoolId;
            M = '&';
        }
        if (!H && app.schoolId) {
            y += M + 'schoolId=' + app.schoolId;
            M = '&';
        }
        if (app.keyword) {
            y += M + 'keyword=' + app.keyword;
            M = '&';
        }
        if (app.fromCity) {
            y += M + 'fromCity=' + app.fromCity;
            M = '&';
        }
        if (app.from) {
            y += M + 'from=' + app.from;
            M = '&';
        }
        if ($reset) {
            y += M + 'reset=' + $reset;
        }
        if ('/' === y.charAt(y.length - 1)) {
            y = y.substring(0, y.length - 1);
        }
        location.href = y;
    }

    $('.checkbox-body .options').not('.js-multiple').on('tap', 'a', cellA = function (y) {
        y.preventDefault();
        y.stopPropagation();
        var A = $(this);
        var z = A.closest('.options');
        if (!A.hasClass('current')) {
            z.find('a').removeClass('current');
            z.data('v', A.data('v'));
        } else {
            z.data('v', '');
        }
        A.toggleClass('current');
    });
    $('.js-multiple').on('tap', 'a', cellA = function (B) {
        B.preventDefault();
        B.stopPropagation();
        var D = $(this);
        var C = D.closest('.options');
        if (!D.hasClass('current')) {
            var z = C.data('v');
            if (z) {
                z = z + '-' + D.data('v');
            } else {
                z = D.data('v');
            }
            C.data('v', z);
        } else {
            var z = C.data('v');
            var A = new RegExp(D.data('v') + '-?|-?' + D.data('v'));
            console.log('regex ' + A);
            if (z) {
                z = z.replace(A, '');
            }
            C.data('v', z);
        }
        D.toggleClass('current');
        var y = D.closest('.items-box');
        if (y && y.hasClass('js-unitPrice-box')) {
            $('#minUnitPrice').val('');
            $('#maxUnitPrice').val('');
        }
        if (y && y.hasClass('js-price-box')) {
            $('#minPrice').val('');
            $('#maxPrice').val('');
        }
    });
    var q = $('#fromPriceVal').val();
    var a = $('#toPriceVal').val();
    var x = $('#fromUnitPriceVal').val();
    var w = $('#toUnitPriceVal').val();
    var o = '';
    if (q && a) {
        o = 'fromPrice=' + q + '&toPrice=' + a;
    }
    if (x && w) {
        if (o) {
            o += '&fromUnitPrice=' + x + '&toUnitPrice=' + w;
        } else {
            o = 'fromUnitPrice=' + x + '&toUnitPrice=' + w;
        }
    }
    var u = false;
    $('.complete-body').on('tap', '.js-more-cancel', function (z) {
        z.preventDefault();
        z.stopPropagation();
        $('.js-filter-title a').last().removeClass('current');
        var y = $('.checkbox-body .more');
        y.find('a').removeClass('current');
        y.each(function (A, B) {
            $(B).data('v', '');
        });
        u = true;
        if (app.moreArea || app.direction || app.labels || app.ages || app.decoration || app.floor || app.facilities || app.rentType || app.areas || app.features || app.bedRooms || app.propertyTypes || app.newhouseStatus || app.moreSort || app.moreSchoolType || app.moreSchoolGrade) {
            $reset = 'more';
            d();
        }
    });
    $('.complete-body').on('tap', '.js-more-ok', function (y) {
        y.preventDefault();
        y.stopPropagation();
        u = false;
        d();
    });

    function d() {
        var S = $('#params').val();
        var R = $('#labels').val();
        var Q = $('#facilities').val();
        var J = $('#ages').val();
        var I = $('#bedRooms').val();
        var L = $('#directions').val();
        var B = $('#decorations').val();
        var K = $('#floors').val();
        var M = $('#rentTypes').val();
        var F = $('#areas').val();
        var O = $('#saleStatus').val();
        var E = $('#features').val();
        var N = $('#propertyTypes').val();
        var D = {};
        var A = $('.checkbox-body .more');
        A.each(function (T, W) {
            var V = $(W);
            if (V.hasClass('js-multiple')) {
                if (u) {
                    if (R != '') {
                        var U = new RegExp('(' + R + '-?|-' + R + '+$)');
                        S = S.replace(U, '');
                    }
                    if (Q != '') {
                        var U = new RegExp('(' + Q + '-?|-' + Q + '+$)');
                        S = S.replace(U, '');
                    }
                    if (J != '') {
                        var U = new RegExp('(' + J + '-?|-' + J + '+$)');
                        S = S.replace(U, '');
                    }
                    if (I != '' && I.indexOf('y') != -1) {
                        var U = new RegExp('(' + I + '-?|-' + I + '+$)');
                        S = S.replace(U, '');
                    }
                    if (L != '') {
                        var U = new RegExp('(' + L + '-?|-' + L + '+$)');
                        S = S.replace(U, '');
                    }
                    if (B != '') {
                        var U = new RegExp('(' + B + '-?|-' + B + '+$)');
                        S = S.replace(U, '');
                    }
                    if (K != '') {
                        var U = new RegExp('(' + K + '-?|-' + K + '+$)');
                        S = S.replace(U, '');
                    }
                    if (M != '') {
                        var U = new RegExp('(' + M + '-?|-' + M + '+$)');
                        S = S.replace(U, '');
                    }
                    if (F != '') {
                        var U = new RegExp('(' + F + '-?|-' + F + '+$)');
                        S = S.replace(U, '');
                    }
                    if (O != '') {
                        var U = new RegExp('(' + O + '-?|-' + O + '+$)');
                        S = S.replace(U, '');
                    }
                    if (E != '') {
                        var U = new RegExp('(' + E + '-?|-' + E + '+$)');
                        S = S.replace(U, '');
                    }
                    if (N != '') {
                        var U = new RegExp('(' + N + '-?|-' + N + '+$)');
                        S = S.replace(U, '');
                    }
                } else {
                    D[V.data('k')] = V.data('v');
                }
            } else {
                S = p(S, V.data('k'), V.data('v'));
            }
        });
        if (S != '') {
            S = '/' + S;
        }
        setTimeout(function () {
            r();
        }, 200);
        var C = $('#urlTemp').val().replace('{xxx}', S);
        if (o != '') {
            C = C.replace(o, '');
        }
        C = c(C);
        if ('/' === C.charAt(C.length - 1)) {
            C = C.substring(0, C.length - 1);
        }
        if (!$.isEmptyObject(D) && D != null) {
            var y = (S == '') ? '/' : '-';
            if (R != '') {
                C = C.replace(R, '{xxx}');
            }
            if (Q != '') {
                C = C.replace(Q, '{yyy}');
            }
            if (J != '') {
                C = C.replace(J, '{aaa}');
            }
            if (I != '' && I.indexOf('y') != -1) {
                C = C.replace(I, '{bbb}');
            }
            if (L != '') {
                C = C.replace(L, '{iii}');
            }
            if (B != '') {
                C = C.replace(B, '{ddd}');
            }
            if (K != '') {
                C = C.replace(K, '{fff}');
            }
            if (M != '') {
                C = C.replace(M, '{hhh}');
            }
            if (!app.schoolId && F != '') {
                C = C.replace(F, '{eee}');
            }
            if (O != '') {
                C = C.replace(O, '{uuu}');
            }
            if (E != '') {
                C = C.replace(E, '{rrr}');
            }
            if (N != '') {
                C = C.replace(N, '{ttt}');
            }
            if (app.location) {
                C += G + 'location=' + app.location;
            }
            var H = 0;
            $.each(D, function (T, U) {
                var V;
                if (U) {
                    if (T == 'labels' || T == 'facilitys' || T == 'ages' || T == 'bedRooms' || T == 'directions' || T == 'decorations' || T == 'floors' || T == 'rentTypes' || T == 'areas' || T == 'saleStatus' || T == 'features' || T == 'propertyTypes') {
                        V = U;
                    } else {
                        V = T + '=' + U;
                    }
                } else {
                    V = '';
                }
                if (V) {
                    H += 1;
                    if (T == 'labels' && R != '') {
                        C = C.replace('{xxx}', V);
                    } else {
                        if (T == 'facilitys' && Q != '') {
                            C = C.replace('{yyy}', V);
                        } else {
                            if (T == 'ages' && J != '') {
                                C = C.replace('{aaa}', V);
                            } else {
                                if (T == 'bedRooms' && I != '') {
                                    C = C.replace('{bbb}', V);
                                } else {
                                    if (T == 'directions' && L != '') {
                                        C = C.replace('{iii}', V);
                                    } else {
                                        if (T == 'decorations' && B != '') {
                                            C = C.replace('{ddd}', V);
                                        } else {
                                            if (T == 'floors' && K != '') {
                                                C = C.replace('{fff}', V);
                                            } else {
                                                if (T == 'rentTypes' && M != '') {
                                                    C = C.replace('{hhh}', V);
                                                } else {
                                                    if (!app.schoolId && T == 'areas' && F != '') {
                                                        C = C.replace('{eee}', V);
                                                    } else {
                                                        if (T == 'saleStatus' && O != '') {
                                                            C = C.replace('{uuu}', V);
                                                        } else {
                                                            if (T == 'features' && E != '') {
                                                                C = C.replace('{rrr}', V);
                                                            } else {
                                                                if (T == 'propertyTypes' && N != '') {
                                                                    C = C.replace('{ttt}', V);
                                                                } else {
                                                                    if (H > 1) {
                                                                        y = '-';
                                                                    }
                                                                    C += y + V;
                                                                }
                                                            }
                                                        }
                                                    }
                                                }
                                            }
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
            });
        }
        var z = new RegExp('({xxx}-?|-' + '{xxx}+$)');
        C = C.replace(z, '');
        z = new RegExp('({yyy}-?|-' + '{yyy}+$)');
        C = C.replace(z, '');
        z = new RegExp('({aaa}-?|-' + '{aaa}+$)');
        C = C.replace(z, '');
        z = new RegExp('({bbb}-?|-' + '{bbb}+$)');
        C = C.replace(z, '');
        z = new RegExp('({iii}-?|-' + '{iii}+$)');
        C = C.replace(z, '');
        z = new RegExp('({ddd}-?|-' + '{ddd}+$)');
        C = C.replace(z, '');
        z = new RegExp('({fff}-?|-' + '{fff}+$)');
        C = C.replace(z, '');
        z = new RegExp('({hhh}-?|-' + '{hhh}+$)');
        C = C.replace(z, '');
        z = new RegExp('({eee}-?|-' + '{eee}+$)');
        C = C.replace(z, '');
        z = new RegExp('({uuu}-?|-' + '{uuu}+$)');
        C = C.replace(z, '');
        z = new RegExp('({rrr}-?|-' + '{rrr}+$)');
        C = C.replace(z, '');
        z = new RegExp('({ttt}-?|-' + '{ttt}+$)');
        C = C.replace(z, '');
        var G = '?';
        if (o != '') {
            C += G + o;
            G = '&';
        }
        if (app.personId) {
            C += G + 'personId=' + app.personId;
            G = '&';
        }
        var P = false;
        if (app.gardenId && app.schoolId) {
            P = true;
            C += G + 'gardenId=' + app.gardenId;
            C += '&schoolId=' + app.schoolId;
            G = '&';
        }
        if (!P && app.schoolId) {
            C += G + 'schoolId=' + app.schoolId;
            G = '&';
        }
        if (app.keyword) {
            C += G + 'keyword=' + app.keyword;
            G = '&';
        }
        if (app.fromCity) {
            C += G + 'fromCity=' + app.fromCity;
            G = '&';
        }
        if (app.from) {
            C += G + 'from=' + app.from;
            G = '&';
        }
        if ($reset) {
            C += G + 'reset=' + $reset;
        }
        if ('/' === C.charAt(C.length - 1)) {
            C = C.substring(0, C.length - 1);
        }
        location.href = C;
    }

    $('.range-body').on('tap', 'a.ok', function (z) {
        z.preventDefault();
        z.stopPropagation();
        var K = $(this);
        var A = K.data('href');
        var F = $('#params').val();
        var y = $('#fromPriceVal').val();
        var D = $('#toPriceVal').val();
        var G = $('#fromUnitPriceVal').val();
        var J = $('#toUnitPriceVal').val();
        var H = '';
        if (y && D) {
            H = 'fromPrice=' + y + '&toPrice=' + D;
        }
        if (G && J) {
            if (H) {
                H += '&fromUnitPrice=' + G + '&toUnitPrice=' + J;
            } else {
                H = 'fromUnitPrice=' + G + '&toUnitPrice=' + J;
            }
        }
        if (H != '') {
            A = A.replace(H, '');
        }
        A = c(A);
        var C = K.data('v');
        var L = new RegExp('(' + C + '-?|-' + C + ')');
        A = A.replace(L, '');
        if (A.substr(-1) === '/') {
            A = A.substring(0, A.length - 1);
        }
        var B = b.find('.first-slider .text-value').text();
        var E = b.find('.last-slider .text-value').text();
        if (B.indexOf('不限') != -1 && E.indexOf('不限') != -1) {
            if (A.indexOf('/' + C) != -1) {
                A = A.replace('/' + C, '');
            }
            if (A.indexOf(C + '-') != -1) {
                A = A.replace(C + '-', '');
            }
            if (A.indexOf('-' + C) != -1) {
                A = A.replace('-' + C, '');
            }
            setTimeout(function () {
                r();
            }, 200);
            location.href = A;
            return false;
        }
        if (B.indexOf('不限') != -1) {
            B = 0;
        }
        if (E.indexOf('不限') != -1) {
            E = 999999;
        }
        setTimeout(function () {
            r();
        }, 200);
        var N = '?fromPrice=' + B + '&toPrice=' + E;
        A += N;
        var M = '&';
        if (app.personId) {
            A += M + 'personId=' + app.personId;
        }
        var I = false;
        if (app.gardenId && app.schoolId) {
            I = true;
            A += M + 'gardenId=' + app.gardenId;
            A += '&schoolId=' + app.schoolId;
        }
        if (!I && app.schoolId) {
            A += M + 'schoolId=' + app.schoolId;
        }
        if (app.keyword) {
            A += M + 'keyword=' + app.keyword;
        }
        if (app.fromCity) {
            A += M + 'fromCity=' + app.fromCity;
        }
        if (app.from) {
            A += M + 'from=' + app.from;
        }
        if (app.version) {
            A += M + 'version=' + app.version;
        }
        if (app.utm_source) {
            A += M + 'utm_source=' + app.utm_source;
        }
        if (app.utm_term) {
            A += M + 'utm_term=' + app.utm_term;
        }
        if (app.utm_medium) {
            A += M + 'utm_medium=' + app.utm_medium;
        }
        if (app.location) {
            A += M + 'location=' + app.location;
        }
        if (A.substr(-1) === '/') {
            A = A.substring(0, A.length - 1);
        }
        location.href = A;
    });

    function p(B, y, A) {
        A = A || '';
        B = B || '';
        if (B) {
            if (B.match('.*' + y + '\\d+.*')) {
                var z = '';
                if (A == '') {
                    z = new RegExp('(' + y + '\\d+-?|-' + y + '\\d+$)');
                } else {
                    z = new RegExp('(' + y + '\\d+)');
                }
                return B.replace(z, A);
            } else {
                return (A == '') ? B : (B + '-' + A);
            }
        } else {
            return A || '';
        }
    }

    function j(y, z) {
        try {
            sessionStorage.setItem(y, z);
        } catch (A) {
        }
    }

    function i(y) {
        $('.childcontent').each(function (A) {
            $(this).hide();
        });

        function z() {
            var A = '', C = $.Deferred();
            try {
                A = sessionStorage.getItem('location');
            } catch (B) {
            }
            if (!A || A === 'null') {
                if (navigator.geolocation) {
                    navigator.geolocation.getCurrentPosition(function (D) {
                        A = D.coords.latitude + ',' + D.coords.longitude;
                        j('location', A);
                        C.resolve(A);
                    }, function (D) {
                        C.reject(D);
                        $('.js-nearby').removeClass('current');
                    }, {enableHighAccuracy: true, maximumAge: 30000, timeout: 20000});
                } else {
                    C.reject();
                    $('.js-nearby').removeClass('current');
                }
            } else {
                C.resolve(A);
            }
            return C.promise();
        }

        z().then(function (A) {
            var B = 'https://api.map.baidu.com/geocoder/v2/?ak=qXR0gZ8QRuYS6fBcjCsx7Nv0YFezW4uH&output=json&location=' + A;
            $.ajax({url: B, dataType: 'jsonp'}).done(function (D) {
                if (D && D.result && D.result.addressComponent) {
                    r();
                    var E = D.result.addressComponent.city, C = y.attr('href');
                    if (C.indexOf('location=') != -1 && app.location) {
                        C.replace('location=' + app.location, 'location=' + A);
                    } else {
                        C += ((C.indexOf('?') > -1) ? '&' : '?') + 'location=' + A;
                    }
                    if (E.indexOf(cityName) < 0) {
                        var F = cities[E.replace('市', '')];
                        if (F) {
                            if (confirm('当前所在城市是' + cityName + ',附近不可用,是否切换至定位城市' + E + '？')) {
                                var G = $('#params').val(),
                                    C = ctx + '/{city}/' + biz.replace('_', '/') + '/nearby' + ((typeof G != 'undefined' && G != '') ? '/' + G : '');
                                if (C.indexOf('location=') != -1 && app.location) {
                                    C.replace('location=' + app.location, 'location=' + A);
                                } else {
                                    C += '?location=' + A;
                                }
                                window.location.href = C.replace('{city}', F.toLowerCase());
                            }
                        } else {
                        }
                    } else {
                        window.location.href = window.location.href = C.replace('{city}', city);
                    }
                }
            });
        }, function () {
            r();
        });
    }
});
$(function () {
    var c = $('.article-body').data('has-more'), g = false, f = 3, h = app.biz + '-list';
    if (app.biz == 'sale' || app.biz == 'rent' || app.biz == 'newhouse' || app.biz == 'garden') {
        h = 'house-list';
    } else {
        if (app.biz.indexOf('office') > -1) {
            h = 'house-list .items';
        } else {
            if (app.biz == 'groupbuy') {
                h = 'group-list';
            } else {
                if (app.biz == 'school') {
                    h = 'scholar-list';
                }
            }
        }
    }
    var a = ($('.header-body').length ? $('.header-body') : $('.header-level')).outerHeight(true);
    var i;
    $(document).on('scroll', e);
    $(document).on('scroll', d);

    function d() {
        var k = a + $('.search-body').outerHeight(true), l = $('.screening-body').outerHeight(true);
        if ($(document).scrollTop() >= k) {
            $('.screening-body').css({'position': 'fixed'});
            $('.article-body').css({'margin-top': l});
        } else {
            $('.screening-body').css({'position': 'relative'});
            $('.article-body').css({'margin-top': 0});
        }
        k = $(window).height() / 2;
        if ($(document).scrollTop() > k) {
            $('.go-top').show();
        } else {
            $('.go-top').hide();
        }
    }

    function e() {
        if (!c) {
            $(document).off('scroll', e);
            j();
            $('.js-list-loading p').text('没有更多房源了');
            $('.js-list-loading').show();
            var l = document.querySelectorAll('img[data-echo], [data-echo-background]').length;
            return;
        }
        var k = $('body').outerHeight(true) - $(window).height() - $('.footer-body').outerHeight(true) - 200;
        if ($(document).scrollTop() > k && ($('.loading') && !$('.loading').is(':visible'))) {
            b();
            if (i) {
                clearTimeout(i);
            }
            i = setTimeout(function () {
                if (!c) {
                    return;
                }
                /*var m = location.href;
                if (m.indexOf('?') != -1) {
                    m += '&page=' + f;
                } else {
                    m += '?page=' + f;
                }
                $.post(m, {more: f}).done(function (o) {
                    if (o) {
                        var n = $('<div>').append(o);
                        c = n.children().length >= 10;
                        if (app.biz != 'sale' && app.biz != 'rent' && app.biz != 'newhouse' && app.biz != 'garden') {
                            $('.article-body .' + h).last().after(o);
                        } else {
                            $('.article-body .house-list .items').last().after(o);
                        }
                    } else {
                        c = false;
                    }
                    if (!c) {
                        j();
                        $('.js-list-loading p').text('没有更多房源了');
                        $('.js-list-loading').show();
                    }
                    f += 1;
                    setTimeout(function () {
                        if (c) {
                            j();
                            $('.list-loading').hide();
                        }
                    }, 100);
                });*/
            }, 150);
        }
    }

    $('.recommend-link a').tap(function (k) {
        k.originalEvent.stopPropagation();
        k.originalEvent.preventDefault();
        $('.article-body').html($('.js-recommend').html());
        window.scrollTo(0, 1);
    });

    function b() {
        $('.js-loading').show();
    }

    function j() {
        $('.js-loading').hide();
    }
}());